<?php

class Kurs extends Controller {

	function parse()
	{
		return;

		$percents = array(20, 30, 40, 50, 60, 45, 55, 65, 75);
		$arr = file('kurs.txt');
		$date = '';
		$key = 0;
		foreach($arr as $row)
		{
			$data = trim($row);
			if($data == '')
			{
				continue;
			}
			if($data == '<tr>')
			{
				$date = '';
				$key = 0;
				continue;
			}
			if($date == '')
			{
				list($day, $month, $year) = explode('.', $data);
				$date = $year.'-'.$month.'-'.$day;
				continue;
			}
			list($buy, $sell) = explode(" ", $data);
			$buy = trim(str_replace(",", "", $buy));
			$sell = trim(str_replace(",", "", $sell));
			$percent = $percents[$key];
			$save = array(
				'date' => $date,
				'percent' => $percent,
				'buy' => $buy,
				'sell' => $sell,
			);
			$id = 0;
			$this->MKurs->save($save, $id);
			$key++;
		}
	}
}
?>